home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / Syslog Component / __Build Fat Component.r next >
Encoding:
Text File  |  1995-11-15  |  8.0 KB  |  190 lines  |  [TEXT/SPM ]

  1. #include <MixedMode.r>
  2. #include <FatRSRC.r>
  3.  
  4. #define FAT            1
  5. #define SAFE        1
  6. #define SAFER        1
  7. #define CURRENTISA    0
  8. #define SHRINKING    1
  9.  
  10. #define ResType            'CODE'                    //    Change to the type of resource you wish to create
  11. #define ResID            300                        //    Change to the ID of resource you wish to create
  12. #define ResName            "Syslog Component (Fat)"    //    Change to the name of the resource you wish to create
  13.  
  14. #define PPCResFile        "Syslog.π.rsrc"            //    Change to the name of this project's resource file
  15. #define PPCProcInfo        $000003F0                //    Change to ProcInfo value for your resource's PowerPC code
  16.  
  17. #define M68KResFile        "68K Syslog code.rsrc"    //    If FAT, Change to name of the file to merge a 68K resource from
  18. #define M68KResType    'CODE'                    //    If FAT, Change to the type of 68K resource to merge in
  19. #define M68KResID        301                        //    If FAT, Change to the ID of 68K resource to merge in
  20.  
  21. #define M68KProcInfo    $0                        //    Change to ProcInfo value for your fat resource's 68K code
  22.  
  23. /*
  24.     Prepend a routine descriptor (from a 'rdes', 'fdes', 'Fdes', 'sdes', 'Sdes', 'ades', 'Ades' or
  25.     '<des' template) to our temporary resource and store it into a resource with the type and ID
  26.     specified by ResType and ResID.
  27.     
  28.     •    Change the ResType and ResID macros to the resource type and ID you wish to create.
  29.     
  30.     •    Change the PPCResFile macro to the name of this project's resource file.  
  31.  
  32.     •    Change the PPCProcInfo macro to the ProcInfo value for your resource's PowerPC code.  
  33.  
  34.     •    If creating a "Fat" code resource, change the M68KResFile macro to the name of the file to
  35.         merge a 68K resource from.  
  36.  
  37.     •    If creating a "Fat" code resource, change the M68KResType and M68KResID macros to the
  38.         resource type and ID of a 68K resource to merge in.
  39.  
  40.     •    If creating a "Fat" code resource, change the M68KProcInfo macro to the ProcInfo value for
  41.         your 68K code.  
  42.     
  43.     
  44.     Accelerated (native PowerPC) Code Resource ('rdes' template) :
  45.     
  46.     Set FAT to 0 to build an accelerated (native PowerPC) code resource with the 'rdes' template.
  47.     Resources created with this template can be executed on a PowerMac from either PowerPC or
  48.     68K mode.  Calling the resource from 68K code (in emulation) will cause a mode switch.
  49.     Resources created with this template are unusable on 68K Macs.
  50.     
  51.     Fat Code Resource ('fdes' template) :
  52.     
  53.     Set FAT to 1, SAFE to 0, and CURRENTISA to 0 to build a "Fat" code resource with the 'fdes'
  54.     template.  If a resource created with this template is used on a 68K Mac, the 68K portion of the
  55.     code resource will be executed.  If it's used on a PowerMac, the PowerPC portion of the code
  56.     resource will be executed.  You would use this template if, when running on a PowerMac in 68K
  57.     emulation, there is less overhead switching to PowerPC mode and executing your PowerPC code
  58.     than executing your 68K code.  Resources created with this template require the Mixed Mode
  59.     Manager to run on a 68K Mac.
  60.     
  61.     Fat Code Resource dependant on current mode ('Fdes' template) :
  62.     
  63.     Set FAT to 1, SAFE to 0, and CURRENTISA to 1 to build a "Fat" code resource, which is dependant
  64.     on the current mode, with the 'Fdes' template.  Code resources created with this template will
  65.     minimize mode switches by executing your PowerPC code if called by PowerPC code (not in 68K
  66.     emulation), and executing your 68K code if called in emulation (or on a 68K Mac).  You would use
  67.     this template if, when running on a PowerMac in 68K emulation, there is less overhead executing
  68.     your 68K code than switching modes and executing your PowerPC code.  Only use this template if
  69.     your code resource, when running on a PowerMac, might be executed by either 68K or PowerPC
  70.     code.  Resources created with this template require the Mixed Mode Manager to run on a 68K Mac.
  71.     
  72.     Safe Fat Code Resource ('sdes' template) :
  73.     
  74.     Set FAT to 1, SAFE to 1, SAFER to 0, SHRINKING to 0, and CURRENTISA to 0 to build a "Safe
  75.     Fat" code resource with the 'sdes' template.  Code resources created with this template are
  76.     similar to those created by the 'fdes' template (described above), but will run on a 68K Mac
  77.     with or without the Mixed Mode Manager.
  78.     
  79.     Safe Fat Code Resource dependant on current mode ('Sdes' template) :
  80.     
  81.     Set FAT to 1, SAFE to 1, SAFER to 0, SHRINKING to 0, and CURRENTISA to 1 to build a "Safe
  82.     Fat" code resource, which is dependant on the current mode, with the 'Sdes' template.  Code
  83.     resources created with this template are similar to those created with the 'Fdes' template
  84.     (described above), but will run on a 68K Mac with or without the Mixed Mode Manager.
  85.  
  86.     Safer Fat Code Resource ('ades' template) :
  87.     
  88.     Set FAT to 1, SAFE to 1, SAFER to 1, SHRINKING to 0, and CURRENTISA to 0 to build a "Safer
  89.     Fat" code resource with the 'ades' template.  Code resources created with this template are
  90.     similar to those created with the 'sdes' template (described above).  The 'sdes' template was
  91.     inherited from MPW.  We provide a "Safer" code resource template to work around some
  92.     potential problems with the 'sdes' template.  Code resources created with this template support
  93.     register-based calling conventions, and 68K Macs without instruction caches.
  94.     
  95.     Safer Fat Code Resource dependant on current mode ('Ades' template) :
  96.     
  97.     Set FAT to 1, SAFE to 1, SAFER to 1, SHRINKING to 0, and CURRENTISA to 1 to build a "Safer
  98.     Fat" code resource, which is dependant on the current mode, with the 'Ades' template.  Code
  99.     resources created with this template are similar to those created with the 'Sdes' template
  100.     (described above), but works around some potential problems with it.  Code resources created
  101.     with this template supports register-based calling conventions, and 68K Macs without
  102.     instruction caches.
  103.     
  104.     Shrinking Safe Fat Code Resource ('<des' template) :
  105.     
  106.     Set FAT to 1, SAFE to 1, and SHRINKING to 1 to create a "Shrinking Safe Fat" code resource
  107.     with the '<des' template.  You would use this template if, when running on a PowerMac in
  108.     68K emulation, there is less overhead switching to PowerPC mode and executing your
  109.     PowerPC code than executing your 68K code.  This resource will determine what type of Mac
  110.     you are using.  If you are using a 68K Mac, the PowerPC code will be truncated from the end
  111.     of the resource in memory.  If you are using a PowerMac, the PowerPC code will be moved to
  112.     the start of the resource, and the left-over space will be truncated from the end of the
  113.     resource in memory.  This type of resource will run natively to either platform, and will not
  114.     keep unused code in memory.
  115.     
  116.     
  117. !!!    Beware, the 68K register A0 will not point to the start of your resource upon entry.  Some
  118. !!!    68K code resources rely on this.  For example, many INIT's pass A0 to RecoverHandle, to get a
  119. !!!    Handle to their code, to detach it (with DetachResource) from its resource file.  Instead, INIT's
  120. !!!    should use Get1Resource to get this Handle.
  121. !!!
  122. !!!    The SetUpA4-related routines will work properly in the 68K code of a "Fat" resource.
  123.     
  124.     • This file does not set any resource attributes for your code resource.  You must specify your
  125.     resource attributes below (ala Rez), or set them once your resource is built, with ResEdit.
  126.     
  127.     • To create your code resource, simply bring this project up to date.  You do not need to
  128.     generate a target.  Your code resource will be saved to your project's resource file.
  129.  
  130.     • This file must be compiled AFTER "_CopyToResource.r"
  131.     
  132.     Colen Garoutte-Carson
  133.     Symantec Corp.
  134. */
  135.  
  136. #if FAT
  137.     #if SAFE
  138.         #if SHRINKING
  139.             type ResType as '<des';
  140.         #else
  141.             #if SAFER
  142.                 #if CURRENTISA
  143.                     type ResType as 'Ades';
  144.                 #else
  145.                     type ResType as 'ades';
  146.                 #endif
  147.             #else
  148.                 #if CURRENTISA
  149.                     type ResType as 'Sdes';
  150.                 #else
  151.                     type ResType as 'sdes';
  152.                 #endif
  153.             #endif    
  154.         #endif
  155.     #else
  156.         #if CURRENTISA
  157.             type ResType as 'Fdes';
  158.         #else
  159.             type ResType as 'fdes';
  160.         #endif
  161.     #endif
  162. #else
  163.     type ResType as 'rdes';
  164. #endif
  165.  
  166. resource ResType (ResID,ResName) {
  167. #if FAT
  168.     #if SAFE
  169.         #if !SHRINKING
  170.             M68KProcInfo,
  171.             PPCProcInfo,
  172.         #endif
  173.     #else
  174.         M68KProcInfo,
  175.         PPCProcInfo,
  176.     #endif
  177. #else    
  178.     PPCProcInfo,
  179. #endif
  180. #if FAT
  181.     $$Resource(M68KResFile, M68KResType, M68KResID),
  182.     #if SAFE
  183.         #if SHRINKING
  184.             PPCProcInfo,
  185.         #endif
  186.     #endif
  187. #endif
  188.     $$Resource(PPCResFile, 'TEMP', 0)
  189. };
  190.